package io.renren.modules.bs.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.renren.modules.bs.entity.BsDepartmentAdministratorEntity;
import io.renren.modules.bs.vo.DepartmentAdministratorVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * 
 * 
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-08-15 23:03:15
 */
@Mapper
public interface BsDepartmentAdministratorDao extends BaseMapper<BsDepartmentAdministratorEntity> {

    @Select("<script>" +
            "SELECT count(1) from bs_department_administrator ad\n" +
            "LEFT JOIN bs_department dept on ad.department_id = dept.department_id\n" +
            "WHERE 1=1\n" +
            "<if test='hospitalId!=null and hospitalId!=\"\"'>" +
            "and dept.hospital_id = #{hospitalId}" +
            "</if>" +
            "</script>")
    Integer getTotal(Map<String, Object> params);

    @Select("<script>" +
            "SELECT da.*,dept.department_name,hosp.hospital_name from bs_department_administrator da\n" +
            "LEFT JOIN bs_department dept on da.department_id = dept.department_id\n" +
            "LEFT JOIN bs_hospital hosp on dept.hospital_id = hosp.hospital_id\n" +
            "WHERE 1=1\n" +
            "<if test='hospitalId!=null and hospitalId != \"\"'>" +
            "and dept.hospital_id = #{hospitalId}" +
            "</if>" +
            " limit #{start},#{limit}" +
            "</script>")
    List<DepartmentAdministratorVo> getPageList(Map<String, Object> params);
}
